import React from 'react'
// v5  Switch
// v6  Routes
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom'
import Index from './layout/main/index.jsx'
import Login from './views/login/Index.jsx'

import { connect } from 'react-redux'
function App({ loginState }) {
  console.log(loginState)
  return (
    <HashRouter>
      <Switch>
        {/* <Route path="/login" component = { Login } /> */}
        <Route path = "/login" >
          {
            loginState ? <Redirect to="/" /> : <Login />
          }
        </Route>
        {/* v6 <Route path="/" element={<Index/>} /> */}
        {/* v5 <Route path="/"><Index /></Route> */}
        {/* v5 <Route path="/" render = { () => <Index /> }></Route> */}
        <Route path="/" component = { Index } />
      </Switch>
    </HashRouter>
  )
}

export default connect(state => ({
  loginState: state.getIn(['user', 'loginState'])
}))(App)
